import { MenuResponseData, MunuData, roleData, roleDataRes } from "@/types/role";
import http from "@/utils/request";

//获取角色信息
export const getRoleDetailAPI=(page:number,limit:number,roleName:string)=>{
    return http<any,roleDataRes>({
        url:`/admin/acl/role/${page}/${limit}/?roleName=${roleName}`
    })
}

//添加职位
export const addPostionAPI=(data:roleData)=>{
    return http<any,any>({
        url:'/admin/acl/role/save',
        method:'post',
        data
    })
}
//编辑职位
export const updatePostionAPI=(data:roleData)=>{
    return http<any,any>({
        url:'/admin/acl/role/update',
        method:'put',
        data
    })
}
// 删除职位
export const delPostionAPI=(id:number)=>{
    return http<any,any>({
        url:`/admin/acl/role/remove/${id}`,
        method:'delete',
    })
}

//获取全部菜单
export const getPostionMenuAPI=(roleId:number)=>{
    return http<any,MenuResponseData>({
        url:`/admin/acl/permission/toAssign/${roleId}`,
    })
}

//给角色分配权限
export const setRolePostionAPI=(roleId:number,permissionId:number)=>{
    return http<any,MenuResponseData>({
        url:`/admin/acl/permission/doAssign/?roleId=${roleId}&permissionId=${permissionId}`,
        method:'post',
    })
}

//获取菜单
export const getMenuAPI=()=>{
    return http<any,MenuResponseData>({
        url:'/admin/acl/permission',
    })
}

// 添加菜单
export const addMenuAPI=(data:MunuData)=>{
    return http<any,any>({
        url:'/admin/acl/permission/save',
        method:'post',
        data
    })
}

// 添加菜单
export const updateMenuAPI=(data:MunuData)=>{
    return http<any,any>({
        url:'/admin/acl/permission/update',
        method:'put',
        data
    })
}
//删除菜单
export const delMenuAPI=(id:number)=>{
    return http<any,any>({
        url:`/admin/acl/permission/remove/${id}`,
        method:'delete'
    })
}